﻿using System.Data.Entity.ModelConfiguration;

namespace CS795.TravelAgency.Domain.Entities.Configurations
{
    public class UserConfiguration : EntityTypeConfiguration<User>
    {
        public UserConfiguration()
        {
            HasKey(p => p.Id);
            Property(p => p.Name).HasMaxLength(50).IsRequired();
            Property(p => p.Email).HasMaxLength(50).IsRequired();
            Property(p => p.Salt).HasMaxLength(10).IsRequired();
            Property(p => p.Password).HasMaxLength(100).IsRequired();
            HasMany(p => p.Roles).WithMany(r => r.Users).Map(m => m.MapLeftKey("UserId").MapRightKey("RoleId").ToTable("UserRoles"));
        }
    }
}
